<template>
	<view>
		<cu-custom bgColor="bg-blue"  :isBack="true"><block slot="content">样品报告</block></cu-custom>
		<view class="cu-bar solid-bottom justify-center">
			<view class="action">南美白对虾病原体基因检验记录单</view>
		</view>
		<view class="bg-white margin">
			<view class="grid col-2">
				<view class="padding-left-lg margin-top-xs">
					<text class="text-black">客户姓名：</text>
					<text class="text-grey">{{orderDetail.order.submitName}}</text>
				</view>
				<view class="padding-left-lg margin-top-xs">
					<text class="text-black">手机号：</text>
					<text class="text-grey">{{orderDetail.order.submitPhone}}</text>
				</view>
			</view>
			<view class="grid col-2">
				<view class="padding-left-lg margin-top-xs">
					<text class="text-black">样品种类：</text>
					<text class="text-grey">{{orderDetail.simpleTypeName}}</text>
				</view>
				<view class="padding-left-lg margin-top-xs">
					<text class="text-black">送检日期：</text>
					<text class="text-grey">{{orderDetail.order.submitDate}}</text>
				</view>
			</view>
			<view class="grid col-2">
				<view class="padding-left-lg margin-tb-xs">
					<text class="text-black">订单号：</text>
					<text class="text-grey">{{orderDetail.order.orderNumber}}</text>
				</view>
				<view class="padding-left-lg margin-tb-xs">
					<text class="text-black">样品编号：</text>
					<text class="text-grey">{{orderDetail.orderNumber}}</text>
				</view>
			</view>
			
			<view class="grid col-1">
				<view class="padding-left-lg margin-tb-xs">
					<text class="text-black">原始编码：</text>
					<text class="text-grey">{{orderDetail.originalCode?orderDetail.originalCode:""}}</text>
				</view>
			</view>
			<view class="grid col-1">
				<view class="padding-left-lg margin-tb-xs">
					<text class="text-black">接收员：</text>
					<text class="text-grey">{{orderDetail.order.acceptUserName}}</text>
				</view>
				
			</view>
			<view v-if="orderDetail.state>=30&&orderDetail.reviewUserName" class="grid col-1">
				<view class="padding-left-lg margin-tb-xs">
					<text class="text-black">复核人：</text>
					<text class="text-grey">{{orderDetail.reviewUserName}}</text>
				</view>
			</view>
		</view>
		<view class="cu-bar">
			<view class="action text-bold">
				一、性能检测<text  v-if="orderDetail.state==20" class="text-red">({{orderDetail.norm}})</text>
			</view>
		</view>
		<view class="margin">
			<view class="flex ">
				<view class="basis-df text-center border  padding-lr-xs padding-tb">检测指标</view>
				<view class="basis-df text-center border  padding-lr-xs padding-tb">检验结果</view>
			</view>
			
			<view v-if="orderDetail.norm=='弧菌平板'" class="flex">
				<view class="basis-df text-center border  padding-lr-xs padding-tb">黄弧菌</view>
				<checkbox-group @change="checkChange" id="ahpnsEms" class="basis-df text-center flex justify-center border  padding-lr-xs padding-tb">
					<label >
						<checkbox :checked="orderDetail.report.ahpnsEms=='positive'" :disabled="orderDetail.state>30" value="positive" style="transform: scale(0.6)" />
						有
					</label >
					
					<label  class="margin-left">
						<checkbox :checked="orderDetail.report.ahpnsEms=='negative'" :disabled="orderDetail.state>30" value="negative" style="transform: scale(0.6)" />
						无
					</label >
				</checkbox-group>
			</view>
			<view v-if="orderDetail.norm=='弧菌平板'" class="flex">
				<view class="basis-df text-center border  padding-lr-xs padding-tb">绿弧菌</view>
				<checkbox-group @change="checkChange" id="wsd" class="basis-df text-center flex justify-center border  padding-lr-xs padding-tb">
					<label>
						<checkbox :checked="orderDetail.report.wsd=='positive'" :disabled="orderDetail.state>30" value="positive" style="transform: scale(0.6)" />
						有
					</label>
					
					<label class="margin-left">
						<checkbox :checked="orderDetail.report.wsd=='negative'" :disabled="orderDetail.state>30" value="negative" style="transform: scale(0.6)" />
						无
					</label>
				</checkbox-group>
			</view>
			<view v-if="orderDetail.norm!='弧菌平板'" class="flex">
				<view class="basis-df text-center border  padding-lr-xs padding-tb">急性肝胰腺坏死病（AHPNS/EMS）</view>
				<checkbox-group @change="checkChange" id="ahpnsEms" class="basis-df text-center flex justify-center border  padding-lr-xs padding-tb">
					<label >
						<checkbox :checked="orderDetail.report.ahpnsEms!='negative'" :disabled="orderDetail.state>30" style="transform: scale(0.6)" />
						阳性
					</label >
					<label class="input-label">
						<input v-if="orderDetail.report.ahpnsEms!='negative'" placeholder="请输入" v-model="orderDetail.report.ahpnsEms" name="input" :disabled="orderDetail.state>30" class="input-small text-left" ></input>
					</label>
					<label>
						<checkbox :checked="orderDetail.report.ahpnsEms=='negative'" :disabled="orderDetail.state>30" value="negative" style="transform: scale(0.6)" />
						阴性
					</label >
				</checkbox-group>
			</view>
			<view v-if="orderDetail.norm!='弧菌平板'" class="flex">
				<view class="basis-df text-center border  padding-lr-xs padding-tb">对虾白斑浊病（WSD）</view>
				<checkbox-group @change="checkChange" id="wsd" class="basis-df text-center flex justify-center border  padding-lr-xs padding-tb">
					<label>
						<checkbox :checked="orderDetail.report.wsd!='negative'" :disabled="orderDetail.state>30" style="transform: scale(0.6)" />
						阳性
					</label>
					<label  class="input-label">
						<input v-if="orderDetail.report.wsd!='negative'" placeholder="请输入" v-model="orderDetail.report.wsd" name="input" :disabled="orderDetail.state>30" class="input-small text-left" ></input>
					</label>
					<label >
						<checkbox :checked="orderDetail.report.wsd=='negative'" :disabled="orderDetail.state>30" value="negative" style="transform: scale(0.6)" />
						阴性
					</label>
				</checkbox-group>
			</view>
			<view v-if="orderDetail.norm!='弧菌平板'" class="flex">
				<view class="basis-df text-center border  padding-lr-xs padding-tb">皮下及造血组织坏死病毒（IHHNV）</view>
				<checkbox-group @change="checkChange" id="ihhnv" class="basis-df text-center flex justify-center border  padding-lr-xs padding-tb">
					<label>
						<checkbox :checked="orderDetail.report.ihhnv!='negative'" :disabled="orderDetail.state>30" style="transform: scale(0.6)" />
						阳性
					</label>
					<label  class="input-label">
						<input v-if="orderDetail.report.ihhnv!='negative'" placeholder="请输入" v-model="orderDetail.report.ihhnv" name="input" :disabled="orderDetail.state>30" class="input-small text-left" ></input>
					</label>
					<label >
						<checkbox :checked="orderDetail.report.ihhnv=='negative'" :disabled="orderDetail.state>30" value="negative" style="transform: scale(0.6)" />
						阴性
					</label>
					
				</checkbox-group>
			</view>
			<view v-if="orderDetail.norm!='弧菌平板'" class="flex">
				<view class="basis-df text-center border  padding-lr-xs padding-tb">肝肠胞虫（EHP）</view>
				<checkbox-group @change="checkChange" id="ehp" class="basis-df text-center flex justify-center border  padding-lr-xs padding-tb">
					<label>
						<checkbox :checked="orderDetail.report.ehp!='negative'" :disabled="orderDetail.state>30" style="transform: scale(0.6)" />
						阳性
					</label>
					<label  class="input-label">
						<input v-if="orderDetail.report.ehp!='negative'" placeholder="请输入" v-model="orderDetail.report.ehp" name="input" :disabled="orderDetail.state>30" class="input-small text-left" ></input>
					</label>
					<label >
						<checkbox :checked="orderDetail.report.ehp=='negative'" :disabled="orderDetail.state>30" value="negative" style="transform: scale(0.6)" />
						阴性
					</label>
				</checkbox-group>
			</view>
			<view v-if="orderDetail.norm!='弧菌平板'" class="flex margin-bottom-xl">
				<view class="basis-df text-center border padding-lr-xs padding-tb">虾血虹彩病毒(SHIV)</view>
				<checkbox-group @change="checkChange" id="shiv" class="basis-df text-center flex justify-center border padding-lr-xs padding-tb">
					<label>
						<checkbox :checked="orderDetail.report.shiv!='negative'" :disabled="orderDetail.state>30" style="transform: scale(0.6)" />
						阳性
					</label>
					<label class="input-label">
						<input v-if="orderDetail.report.shiv!='negative'" placeholder="请输入" v-model="orderDetail.report.shiv" name="input" :disabled="orderDetail.state>30" class="input-small text-left" ></input>
					</label>
					<label >
						<checkbox :checked="orderDetail.report.shiv=='negative'" :disabled="orderDetail.state>30" value="negative" style="transform: scale(0.6)" />
						阴性
					</label>
				</checkbox-group>
			</view>
		</view>
		<view class="solids-bottom padding-xs flex align-center padding-bottom-lg margin-bottom-lg">
			<view class="flex-sub text-center">
				<view class="solid-bottom text-xl padding">
					<text class="text-black text-bold">质检合格放行</text>
				</view>
				<view class="padding text-xs">执行标准：弧菌显色平板法（国家标准 GB 4789.7/2013），《医疗机构临床实验室管理方法》（卫办医政发〔2010〕194号），南美白对虾五项病原体检测试剂盒（基因芯片法）使用说明。</view>
			</view>
			<view class="shuiyin">
				<image src="../../../static/img/shuiyin.png" class="shuiyin-img"></image>
			</view>
		</view>
		<view v-if="orderDetail.state==20" class="cu-bar tabbar bg-white shadow foot">
			<view class="cu-bar btn-group">
				<button class="cu-btn  bg-green shadow" @tap="updateOrderDetailSave">生成报告</button>
			</view>
		</view>
		<view v-if="orderDetail.state==30 && roles.indexOf('review')!=-1" class="cu-bar tabbar bg-white shadow foot">
			<view class="cu-bar btn-group">
				<button class="cu-btn  bg-green shadow" @tap="reviewOrderDetailUpdate">确认无误</button>
			</view>
		</view>
		<view v-if="orderDetail.state==40 && roles.indexOf('payed')!=-1" class="cu-bar tabbar bg-white shadow foot">
			<view class="cu-bar btn-group">
				<button class="cu-btn  bg-green shadow" @tap="payedOrderDetailUpdate">确认付款</button>
			</view>
		</view>
	</view>
</template>

<script>
	import { getOrderDetail,updateOrderDetail} from '@/api/modules/orderDetail.js'
	export default {
		name:"acceptOrderDetail",
		data() {
			return {
				orderDetailId:"",
				roles:uni.getStorageSync('roles'),
				member:uni.getStorageSync('member'),
				orderDetail:{}
			}
		},
		onLoad(options) {
			this.orderDetailId=options.orderDetailId
		},
		onReady() {
			this.getOrderDetailReport()
		},
		methods: {
			getOrderDetailReport(){
				let self=this
				getOrderDetail(this.orderDetailId).then(res=>{
					if(res.data.code==200){
						self.orderDetail=res.data.data
						if(self.orderDetail.state==30 && self.roles.indexOf('review')!=-1){
							self.orderDetail.reviewUserId=self.member.userId
							self.orderDetail.reviewUserName=self.member.nickName
						}
					}
				})
			},
			//出报告
			updateOrderDetailSave(){
				let self=this
				// if(self.orderDetail.report.packingIntact==null ||
				// 	self.orderDetail.report.ahpnsEms==null ||
				// 	self.orderDetail.report.wsd==null ||
				// 	self.orderDetail.report.ihhnv==null ||
				// 	self.orderDetail.report.ehp==null ||
				// 	self.orderDetail.report.shiv==null){
				// 	uni.showToast({
				// 		title:"填写完整的报告"
				// 	})
				// 	return;
				// }
				uni.showModal({
				    title: '提示',
				    content: '确认生成样品报告？',
				    success: function (res) {
				        if (res.confirm) {
							self.updateOrderDetailDosave()
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			//生成样品报告
			updateOrderDetailDosave(){
				//改变状态为已出报告
				this.orderDetail.state=30
				updateOrderDetail(this.orderDetail).then(res=>{
					if(res.data.code==200){
						uni.showToast({
							title:"生成报告成功"
						})
						setTimeout(function() {
							uni.navigateBack({
								delta:1
							})
						}, 1500);
					}
				})
			},
			reviewOrderDetail(){
				uni.showModal({
				    title: '提示',
				    content: '确认样品报告无误？',
				    success: function (res) {
				        if (res.confirm) {
							self.reviewOrderDetailUpdate()
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			reviewOrderDetailUpdate(){
				//改变状态为已出报告
				this.orderDetail.state=50
				updateOrderDetail(this.orderDetail).then(res=>{
					if(res.data.code==200){
						uni.showToast({
							title:"报告复核成功"
						})
						setTimeout(function() {
							uni.navigateBack({
								delta:1
							})
						}, 1500);
					}
				})
			},
			payedOrderDetailUpdate(){
				//改变状态为已出报告
				this.orderDetail.state=50
				updateOrderDetail(this.orderDetail).then(res=>{
					if(res.data.code==200){
						uni.showToast({
							title:"确认付款成功"
						})
						setTimeout(function() {
							uni.navigateBack({
								delta:1
							})
						}, 1500);
					}
				})
			},
			checkChange(e){
				let reportValue=this.orderDetail.report[e.target.id]
				let value=e.detail.value[e.detail.value.length-1]
			    if(reportValue==value){
                    this.orderDetail.report[e.target.id]=""
				}else{
                    this.orderDetail.report[e.target.id]=""
                    this.orderDetail.report[e.target.id]=value
				}
			}
			
		}
	}
</script>

<style>
page{
	background-color: #f0f0f0;
}
.shuiyin{
	position:absolute;
	top:5upx;
	left:255upx
}
.shuiyin .shuiyin-img{
	width: 250upx;
	height: 130upx;
	opacity: 0.7;
}
.input-label{
	width: 80upx;
	margin-left:10upx;
}
.input-small{
    border-bottom: 5upx solid #ffffff;
	margin-left:10upx;
}
	
</style>
